beginoutdoorscript;

variables;
short bmessage,pcs,others_ok,twondx;
string custom_m;

body;

beginstate 0;

break;

beginstate 1;
break;

beginstate START_STATE;

	if(get_flag(5,0) == 0 && get_flag(2,0) >= 10){
		message_dialog("As you leave the ruination of the campsite behind you, you survey your surroundings.  The Ivalice Mountains lie to your north, at the peak of which lies Fort Ivalice.  It would be a short journey to get there.","If you want to return to Rayguard Province, the road heads back east.  The road also goes south, but the Elibe Province is a ten day's march at least.");
		set_flag(5,0,1);
	}

break;

beginstate 10;

	message_dialog("This is the way to Elibe Province.  Of course, it's a poor way to go down, considering your likelihood of being attacked en route.  Plus, it's much further than the Rayguard Province to the east.","You have better options than this.");
	block_entry(1);

break;

beginstate 11;

	if(get_flag(5,0) < 2){
		reset_dialog();
		add_dialog_str(0,"It's MUCH easier to move about when you don't have a group of tired soldiers dragging you down- it was still a stupid move to set up camp there anyway, but you certainly would have been an easy kill climbing here.",0);
		add_dialog_str(1,"There it is.  Fort Ivalice.  It doesn't look too sophisticated by design, but the vantage point gives off a powerful impression- especially when protection is what you really need right about now.",0);
		add_dialog_str(2,"The fort has high walls, and inside, there is a dim light.  The fort at least appears to be staffed by humans at any rate, although you can't say that for sure.  There's little wreckage or other signs of battle visible.",0);
		add_dialog_str(3,"Based on the situation, there might be a chance for helping these people out.  On the other hand, they could be a skeleton crew, ripe for the picking by any wandering nephil raiders.",0);
		add_dialog_str(4,"The best idea at this point would be to investigate.  Unless nephils and not humans are waiting for you inside  It's your choice.",0);
		bmessage = run_dialog(1);
		set_flag(5,0,2);
	}

break;

beginstate 12;

	if(get_flag(26,0) < 2){
		message_dialog("This is leading away from the fort, and into more dangerous land.  If you want to leave Ivalice Province, the only way is to the east.  Proceeding this way alone would be foolhardy suicide at its best.","");
		block_entry(1);
	}

	if(get_flag(26,0) == 2){
		clear_buffer();
		append_string("_");
		append_char_name(0);
		append_string(", to the west is the watchtower we use to spy on the enemy.  From there, we might be able to get a better look at the Ratbane Clan's new fortress._");
		get_buffer_text(custom_m);
		message_dialog(custom_m,"_I want you to take a good look at it before we descend down the mountain to the south.  Let's go there first._");
		set_flag(26,0,3);
	}

break;

beginstate 13;

	if(get_flag(26,0) == 3){
		reset_dialog();
		add_dialog_str(0,"So this is the so-called watchtower.  It is, indeed, very tall.  The sheer cliff face combined with the tower itself make this structure a very good vantage point.",0);
		add_dialog_str(1,"There is a rope ladder leading up into the viewing area.  If you wanted to, you could climb up the ladder onto the upper part of the tower.",0);
		add_dialog_str(2,"_Come on, friend.  Let's have a peek at the kitties' goings-on._",0);
		add_dialog_choice(0,"Climb up.");
		bmessage = run_dialog(1);

		message_dialog("You get up to the top of the watchtower.  Dervish Malachai points to the north.","_That's the nephil fortress over there._");

		reset_dialog();
		add_dialog_str(0,"It is profoundly large.  It looks like a very solidly-built place as well.  Furthermore, thatched barracks and campfires light the area.  The nephils couldn't have been preparing this for so long without the Empire's notice.",0);
		add_dialog_str(1,"_That is an abandoned Imperial fortress used by General Foottracer when he was invading the area.  It fell into disrepair five years ago when demand for soldiers elsewhere on Valorim left the structure with a skeleton crew._",0);
		add_dialog_str(2,"_The Ratbane nephils, having already gathered a few hundred to their cause, were virtually able to walk into the fort.  At the time, this hollow shell called Fort Ivalice had just neared completion, and the mines were occupied._",0);
		add_dialog_str(3,"_Well, the mines were shut down immediately.  We sent messengers to Kalzas to see if the Marquess would send help.  By the time your group arrived under Biggs' command, we had already sunk to this new low._",0);
		add_dialog_str(4,"_There are lots of nephilim out there.  If we don't stop the influx, this whole valley will soon become one giant encampment, storming with kitties thirsting for blood._",0);
		add_dialog_str(5,"_I don't want to treat these nephilim like they're sub-human.  On the other hand, if I don't eliminate them here and now, it will only cost more lives for both species down the road._",0);
		if(get_flag(99,0) == 1)
			add_dialog_choice(0,"Mm.  To save lives.");
		if(get_flag(99,0) == 2)
			add_dialog_choice(0,"The nephilim are nothing but trouble.");
		bmessage = run_dialog(1);

		reset_dialog();
		if(get_flag(99,0) == 1){
			add_dialog_str(0,"_Those nephilim don't know what they're doing...  They want to liberate themselves of Empire control.  And maybe they're right.  Maybe they deserve to be free.  Heck, you can quote me on that._",0);
			add_dialog_str(1,"_Still, I believe that not only is this a morally wrong way to go about their quest, it is also an act of futility.  The nephilim should not give up their cause, just their swords._",0);
		}
		if(get_flag(99,0) == 2){
			add_dialog_str(0,"_They are troublesome, I agree.  And so are the Empire soldiers under Foottracer who committed acts of genocide to whatever nephil village they went through._  He notes your reaction.",0);
			add_dialog_str(1,"_I...  know this might be difficult to swallow, but imagine if you were the friend of someone who was killed because of his race.  Imagine if you were a child, forced to watch your parents being murdered.  At least try to understand._",0);
		}
		clear_buffer();
		append_string("_Anyway, ");
		append_char_name(0);
		append_string(", that's all I really wanted to say.  C'mon, let's go down.  The abandoned township of Ivalice is to the south, and the war party is to the northeast._");
		get_buffer_text(custom_m);
		add_dialog_str(2,custom_m,0);
		bmessage = run_dialog(1);

		set_total_visibility(0);
		set_flag(26,0,4);
	}

break;

beginstate 14;

	if(get_flag(26,0) < 4){
		message_dialog("_Hey, wait up!  The watchtower is up to the north.  We'll be going this way shortly, so hold your horses, friend._","");
		block_entry(1);
	}

break;

beginstate 14;

	if(get_flag(26,0) > 2){
		message_dialog("_This is the wrong way!  Don't worry, I promise that you'll come back from this expedition safely.  I swear it on my life.  Now back this way, soldier!_","");
		block_entry(1);
	}

break;

beginstate 15;

	if(get_flag(26,0) < 5){
		reset_dialog();
		add_dialog_str(0,"_This is the town of Ivalice- or at least, what was allowed to be completed before the nephils attacked and killed all of the workers in a surprise raid._",0);
		add_dialog_str(1,"_Now, there are a few standing buildings here and what could easily be used as a construction site, but a definite lack of workers.  It would be hell to defend._",0);
		add_dialog_str(2,"_The war party is through the forest to the west.  Head through the foliage, and then turn north.  I'll give more detailed instructions when we get closer._",0);
		bmessage = run_dialog(1);
		set_flag(26,0,5);
	}

break;

beginstate 16;

	if(get_flag(26,0) >= 15){
		message_dialog("You have no more business here.  This camp is still abandoned.","");
		block_entry(1);
	}

break;

beginstate 17;

	if(get_flag(26,0) >= 1 && get_flag(26,0) < 25) == TRUE){
		message_dialog("_Hey!  Wrong way, silly.  The nephils are to the west, not the east._","");
		block_entry(1);
	}

break;

beginstate 18;

	if(get_flag(26,0) >= 15 && get_flag(26,0) < 25){
		message_dialog("_Wait up...  Ivalice isn't that way.  The fort is, but the town isn't, and as much as I hate to say it, I'm really pooped!  Please, let's just stop at the town._","");
		block_entry(1);
	}

break;

beginstate 19;

	if(get_flag(26,0) == 25){
		set_flag(99,5,6);
		set_flag(26,0,26);
		set_flag(44,0,1);
		set_flag(49,0,1);
		set_flag(50,0,1);
	}

break;

beginstate 20;

	set_flag(99,3,0);

break;

beginstate 21;

	set_flag(99,3,1);

break;

beginstate 22;

	set_flag(99,3,2);

break;

beginstate 23;

	set_flag(99,3,3);

break;

beginstate 24;

	if(get_flag(26,0) >= 37 && get_flag(55,0) == 0 && get_flag(26,0) < 60){
		reset_dialog();
		add_dialog_str(0,"_Stop._",0);
		add_dialog_str(1,"Anthony seems a bit impatient.",0);
		add_dialog_str(2,"_I know where this path leads.  It leads back to Kalzas, and away from Ivalice.  Tell me honestly, do you plan to take this path after all?_",0);
		add_dialog_choice(0,"No.");
		add_dialog_choice(1,"Yes.");
		bmessage = run_dialog(0);
		if(bmessage == 1){
			block_entry(1);
			end();
		}

		change_spec_item(1,-1);
		remove_char_from_party(700);
		set_flag(44,0,0);

		reset_dialog();
		clear_buffer();
		append_string("_Very well, ");
		pcs = 0;
		while(pcs <= 3){
			if(char_ok(pcs) == TRUE){
				others_ok = (pcs + 1);
				twondx = 0;
				while(others_ok < 4 && twondx < 2){
					if(char_ok(others_ok) == 1){
						twondx = (twondx + 1);
					}
					others_ok = (others_ok + 1);
				}
				if(twondx == 1){
					append_char_name(pcs);
					append_string(", and ");
				}
				if(twondx > 1){
					append_char_name(pcs);
					append_string(", ");
				}
				if(twondx == 0){
					append_char_name(pcs);
					append_string(".");
				}
			}
			pcs = (pcs + 1);
		}
		append_string("  It has been nice traveling with ");
		if(party_size() > 2)
			append_string("all of ");
		if(party_size() == 2)
			append_string("both of ");
		append_string("you, but if you plan on going this way, then I take my leave.  Farewell._");
		get_buffer_text(custom_m);

		add_dialog_str(0,custom_m,0);
		add_dialog_str(1,"Anthony turns away and begins to travel back up the hill at lightning-fast speed.  You had no idea that he was so fast.",0);
		add_dialog_str(2,"Suddenly, you remember that he tapped your pocket before fleeing.  A cursory search reveals that everything is intact, save for Malachai's key!",0);
		add_dialog_str(3,"Drat.  That wily bugger pickpocketed you.  Does he plan on locking you out of the fort?",0);
		bmessage = run_dialog(1);

		set_flag(55,0,1);
	}

break;

beginstate 25;

	message_dialog("This is the mine.  Incidentally, it is still sealed; you have nothing left to do here.  You're certainly not returning to Fort Ivalice, at any rate.","");
	block_entry(1);

break;

beginstate 26;

	if(get_flag(26,0) < 40){
		message_dialog("Suddenly, the ground seems to be getting a lot drier.  Now that you're leaving the forest, you take a good look around.  Outcroppings of rock are all around, and the only trees are sickly and dying.","_This is nephil land...  We need to go northwest.  Avoid entering that guarded area to the west.  They'd gut us for sure there.  I'll show you the path we'll have to take when we get closer._");
		set_flag(26,0,40);
	}

break;

beginstate 27;

	message_dialog("This path is the incredibly long and perilous road back to the Rayguard Province.  Unfortunately, even without any hazards on the road, you're a good ten days away from Kalzas.","In other words, this way is a no-go.");
	block_entry(1);

break;

beginstate 28;

	message_dialog("Anthony stops you.  _Don't go this way.  They have guardtowers, see?  If we go much further, we'll be spotted for sure._","_Let's go around this place to the north like I told you before._");
	block_entry(1);

break;

beginstate 29;

	if(get_flag(26,0) < 41){
		message_dialog("Anthony points ahead, beyond a small coppice of dying shrubbery.  _Come this way...  This path is difficult to see, but it's pretty broad.  It's the far end of the valley formed by the mountains._","_We'll be safe here, assuming we weren't spotted by that entrance guard south of us._");
		set_flag(26,0,41);
	}

break;

